<template>
	<view class="containers">
		<view class="main-app" style="position: unset;">
			<view class="header">
				<topWallet :getName="names" :isLogins="islogin"></topWallet>
			</view>
			<view class="video-box">
				<video class="tui-video" :src="vedio" ref="video" :controls="false" :autoplay="true"
					:loop="true" objectFit="fill" muted>
				</video>
				<view class="video-box-span">
					<view class="pcoin">
						<image src="../../static/images/common/lcoin.png" mode="widthFix" style="width:100rpx;"></image>
					</view>
				</view>
				<video class="tui-video" :src="vedio" ref="video1" :controls="false"
					:autoplay="true" :loop="true" objectFit="fill" muted>
				</video>
			</view>

		</view>

	</view>
</template>
<script>
	import topWallet from "@/components/nav/top_wallet.vue"
	export default {
		components: {
			topWallet,
		},
		data() {
			return {
				select: 1,
				current: 0,
				open_reg: false,
				isopen: false,
				hasToken: false,
				open_wallet: false,
				vedio: '',
				islogin: false,
				names: this.$t('login'),
			};
		},
		beforeDestroy() {

		},
		onHide() {

		},
		onLoad: function() {

		},

		onShow() {
			if (this.tui.isLogin()) {
				this.islogin = true;
				this.names = this.tui.hidden(uni.getStorageSync("yy_wallet").address, 3, 4)
			} else {
				this.islogin = false;
				this.names = this.$t('login')
			}
			this.init()
		},
		methods: {
			onVideoPlay(event) {
				// 当视频播放时，可以在这里执行其他逻辑
			},
			restartVideo() {
				const video = this.$refs.video;
				const video1 = this.$refs.video1;
				if (video) {
					video.pause(); // 暂停视频
					video.seek(0); // 跳转至视频开始
					video.play(); // 视频重新播放

					video1.pause(); // 暂停视频
					video1.seek(0); // 跳转至视频开始
					video1.play(); // 视频重新播放
				}
			},
			showTips: function(msg, type) {

				let options = {
					msg: msg,
					duration: 2000,
					type: 'default'
				};
				this.$refs.toast.showTips(options);
			},

			init() {
				let datas = {};
				let result = this.tui.request('/api/autos/getvedio', 'post', datas, 1000, 1, '');
				Promise.resolve(result).then((value) => {
					if (value.code == 200) {
						this.vedio = value.data
						this.restartVideo();
					}
				})
			},
			langPop() {
				this.isopen = true
			},
			closeOpen() {
				this.isopen = false
				this.open_wallet = false
			},
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 200)
		},
		onReachBottom: function() {

		},

	};
</script>
<style lang="scss">
	@import '../../static/css/defalut.css';

	page {
		height: 100%;
	}

	.tui-video {
		width: 100%;
		height: 380rpx;
		border-radius: 20rpx;
	}

	.video-box-span {
		position: relative;
		background: rgba(0, 0, 0, 0.4);
		margin: 20rpx 0 26rpx 0;
		border-radius: 20rpx;
	}

	.pcoin {

		// 
		text-align: center;
		padding: 20rpx;
		border-radius: 20rpx;
	}

	.video-box {
		margin: 20rpx;
	}

	.containers {
		// background: url(../../static/images/common/bg.jpg) #000 top no-repeat;

		background-size: 100%;
		margin: 0 !important;
		background: #1a2038;
		// -webkit-filter: brightness(70%);
		// filter: brightness(90%);
		width: 100%;
		height: 100%;

	}
</style>